Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pump-chain

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pump-chain

A module that glues pump and bubble-stream-error to make things easier when your public API returns a stream.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
decreased by-37.1%
Maintainers
1
Weekly downloads
 
Created
Source

pump-chain

A module that glues pump and bubble-stream-error to make life easier when piping streams internally and returning an outer stream.

build status

what problem does it solve?

Consider the situation when you are piping multiple streams internally and returning an outer stream. That stream will be handled by users of your module so you need to make sure that the errors coming from the internal streams propagate to the outer one (which bubble-stream-error takes care of), otherwise they can't be caught and will blow up the process. Also if one of the inner streams closes you want to make sure that the others get closed as well (which pump does).

usage

Simply pass the streams you want to pipe together to pump-chain.

var pump = require('pump-chain');
var crypto = require('crypto');
var fs = require('fs');
var zlib = require('zlib');

function getEncryptedCompressedWordsStream() {
  var gzip = zlib.createGzip();
  var password = new Buffer('car cat tree fireman');
  var aes = crypto.createCipher('aes-256-cbc', password);

  var rs = fs.createReadStream('/usr/share/dict/words');

  // uncomment to simulate an error
  /*
  var i = 0;
  rs.on('data', function() {
    if (++i === 3) {
      this.emit('error', new Error('3 is unlucky!'));
    }
  });
  */

  return pump(rs, aes, gzip);
}

getEncryptedCompressedWordsStream().on('error', function handleError(err) {
  console.error('\n!!! something bad happened while streaming stuff !!!\n');
  throw err;
}).pipe(process.stdout);

tests

npm test

mississippi stream utility collection which includes more useful stream modules similar to this one

license

MIT

FAQs

Package last updated on 27 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc